#include "pch.h"
#include "SurfaceReconstruction.h"
#include <QtWidgets/QApplication>
#include <vtkOutputWindow.h>
#include "Filter.h"
#include "Pipe.h"
#include "FilterPipeSystem.h"
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);

//FUNCTION: detect the memory leak in DEBUG mode
void installMemoryLeakDetector()
{
	// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
	//_CRTDBG_LEAK_CHECK_DF: Perform automatic leak checking at program exit through a call to _CrtDumpMemoryLeaks and generate an error 
	//report if the application failed to free all the memory it allocated. OFF: Do not automatically perform leak checking at program exit.
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	//the following statement is used to trigger a breakpoint when memory leak happens
	//comment it out if there is no memory leak report;
	//_crtBreakAlloc = 6840256;
	//_CrtSetBreakAlloc(126549);
#endif
}

int main(int argc, char *argv[])
{
	installMemoryLeakDetector();
	vtkOutputWindow::SetGlobalWarningDisplay(0);
	QApplication Application(argc, argv);
	AutomatedSurfaceReconstruction::CSurfaceReconstruction Window;
	Window.init();
	Window.show();
	return Application.exec();//memory leak 
}
